package com.hxx.service.impl;

import com.hxx.domain.TUser;
import com.hxx.mapper.UserMapper;
import com.hxx.mapper.impl.UserMapperImpl;
import com.hxx.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {

    private UserMapper userMapper = new UserMapperImpl();
    @Override
    public boolean login(String username, String password) {
        return userMapper.login(username, password);
    }

    @Override
    public void saveUser(TUser user) {
        userMapper.insert(user);
    }

    @Override
    public void updateUser(TUser user) {
        userMapper.update(user);
    }

    @Override
    public TUser findById(Integer id) {
        return userMapper.selectById(id);
    }

    @Override
    public List<TUser> findAll() {
        return userMapper.selectAll();
    }

    @Override
    public void deleteUser(Integer id) {
        userMapper.delete(id);
    }

    @Override
    public List<TUser> findByPage(int pageNo, int pageSize) {
        return userMapper.findByPage((pageNo-1)*pageSize, pageSize);
    }

    @Override
    public int getTotalCount() {
        return userMapper.getTotalCount();
    }
}
